ydata = z(69,:);
xdata = 0:1:length(ydata)-1;
pars0 = [mean(ydata);3000.;2.*pi/100.;pi];
sinErr = @(pars,xdata) pars(1) + pars(2)*sin(pars(3)*xdata + pars(4));
optimset('TolX',1e-8);
[x,resnorm] = lsqcurvefit(sinErr,pars0,xdata,ydata);
ax = subplot(1,1,1);
hold on;
plot(ydata);
plot(sinErr(x,xdata));